package com.ls.es.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @description:
 * @Author liu Weidong
 * @Email:
 * @Date: 2024/7/6 14:42
 * @Version 1.0
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
@Document(indexName = "book")
public class Book {
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String name;
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String author;
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String press;
    @Field(type = FieldType.Text, index = false)
    private String img;
    @Field(name = "publish_time", type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private String publishTime;
    @Field(type = FieldType.Keyword)
    private String type;
    @Field(name = "original_price", type = FieldType.Double)
    private double  originalPrice;
    @Field(name = "current_price", type = FieldType.Double)
    private double currentPrice;
    @Field(type = FieldType.Keyword)
    private String source;
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String des;
}
